import axios from "axios";
const instance = axios.create({
    baseURL: "http://gz.wolfcode.cn/cms",
    timeout: 5000
})

//请求拦截器-会在请求发送前执行
instance.interceptors.request.use(config => {
    if (config.url === '/sendSMS' || config.url === '/phoneRegin') {
        config.headers["Content-Type"] = 'application/x-www-form-urlencoded'
    }
    const token = localStorage.getItem('x-auth-token')
    if (token) {
        config.headers['x-auth-token'] = token
    }
    return config
})

//想要拦截器
instance.interceptors.response.use(res => {
    return res.data
})
export default instance